<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8" />
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<title>趣看趣论</title>
	<link rel="stylesheet" type="text/css" href="../../build/css/base.css"/>
	<link rel="stylesheet" type="text/css" href="../../build/css/main.css">
	<link rel="stylesheet" type="text/css" href="../../build/css/find.css">
	<script type="text/javascript" src="../../build/js/jquery.min.js"></script>
	<script src="../../build/public/vue.js" charset="utf-8"></script>
	<script type="text/javascript" src="../../build/js/template.js"></script>
	<script type="text/javascript" src="../../build/js/config.js"></script>
	<script type="text/javascript" src="../../build/public/base.js"></script>
	<script type="text/javascript" src="../../build/public/vue-resource.js"></script>
	<script type="text/javascript" src="../../build/js/common.js"></script>
</head>
<body>
	<div id="container" class="interest" style="padding-bottom:50px;">
		<find-menu></find-menu>
		<a class="video" v-for="(item,index) in videoList" v-bind:href="item.idStr2" v-if="index <= 0" style="overflow:hidden;">
			 	
			  <video id="videoID" width="100%" height="auto" v-bind:src="item.videoUrl"/>
					
			  </video>
			 	<img v-bind:src="item.pictureUrl2" alt="资招APP" style="height:auto;width:100%;" />
			    <button type="button" class="btnPlay" @click="play"><img src="../../build/images/play.png"/></button>
			    <div class="title" @click="play">
							<p>{{item.title}}</p>
				</div>
				<div class="opacity" @click="play"></div>
		</a>
		<div class="video-list" style="overflow: hidden;">
				<div class="item" v-for="(item,index) in videoList" v-if="index != 0">
					<a v-bind:href="item.idStr2" style="overflow:hidden;">
						<video width="100%" height="150px" preload="none" v-bind:src="item.videoUrl">
						
						</video>
						<img v-bind:src="item.pictureUrl2" alt="资招APP" @click="play"  style="width:auto !important;height:150px;" />
						<button type="button" class="btnPlay" @click="play"><img src="../../build/images/play.png"/></button>												
						<div class="opacity" @click="play"></div>									
					</a>
					<div class="title">
						<p>{{item.title}}</p>
					</div>									
				</div>
		</div>
		<div class="empetDate" v-if="! videoList.length" style="display: block;">
			<span class="iconfont">&#xe602;</span>
			抱歉！没找到更多数据
		</div>
		<my-footer></my-footer>
	</div>
	<script type="text/javascript">
		var vm = new Vue({
			el:"#container",
			data:{
				videoList:[],
				page:1,
				pageCount:0,
				idStr:''
			},
			mounted:function(){
				this.$nextTick(function(){
					this.init()
					refresh(this.refreshData())
				})
			},
			methods:{
				init:function(){
					//初始化
					this.getVideoList()
				},
				getVideoList:function(){
					loader.init()
					get('/discovery/video/list',{
						currentPage:this.page,
						deviceType:'WECHAT'
					},function(res){
						vm.videoList = vm.videoList.concat(res.data.resultList)
						vm.pageCount = res.data.pageSize
						console.log('vm.pageCount = '+vm.pageCount)
						for(var i=0;i<vm.videoList.length;i++){
							vm.videoList[i].idStr2 = 'play.html?idStr='+vm.videoList[i].idStr
							vm.videoList[i].pictureUrl2 = domain+vm.videoList[i].pictureUrl
						}
						if(res.data.resultList.length < 7){
							refreshText('到底了哦！')
						}else{
							refreshText('上拉加载更多数据')
						}
						if(vm.videoList.length <7){
							refreshText('')
						}
						loader.remove()
					},function(res){
						toast(res.error)
					})
				},
				refreshData:function(){
					return function(){
						if(vm.page <= vm.pageCount){
							vm.page++
						    vm.getVideoList()
						}
					}
				},
				play:function(event){
					event.preventDefault()
					clicked = event.target.tagName
					if(clicked == 'IMG'){
						vm.idStr = $(event.target).parent().parent().attr('href').split('=')[1]
					}else if(clicked == 'BUTTON'){
						vm.idStr = $(event.target).parent().attr('href').split('=')[1]
					}else if(clicked == 'DIV'){
						vm.idStr = $(event.target).parent().attr('href').split('=')[1]
					}else if(clicked == 'P'){
						vm.idStr = $(event.target).parent().parent().attr('href').split('=')[1]
					}
					get('/discovery/video/info',{opinionIdStr:vm.idStr},function(res){
						if(res.data.videoUrl){  //判断视频类型 本地 or  链接
							console.log('链接视频' )
							window.location.href = res.data.videoUrl
						}else{
							console.log('本地视频')
							window.location.href = 'play.html?idStr='+vm.idStr
						}
					},function(res){
						console.log(res.error)
					})
				}
			}
			
			
			
			
			
		})
		
		
	
		
	
	</script>
</body>
</html>